﻿<?php
include_once('common/header.php');	
if($AppUI->id <= 0) {
	echo '{';
	echo 	'error: 1' . $error . ",\n";
	echo 	'msg: ' . $arrError[6] . "\n";
	echo '}';
}
$oFile		= $_FILES['pimage'];
$intError	= 0;
$strLink	= '';
if(isset($oFile) && $oFile) {
	$arrImg = Globals::uploadAvatar($oFile,$strPath);	
	if($arrImg['error'] == 0) {		
		$objPhoto 	= new Photo();
		$objPhoto->unlinkImg($AppUI->id, $AppUI->imageid);
		$arrResult	= $objPhoto->add($AppUI->id, $strPath);
		$strLink	= HOST_IMG_AVATAR_THUMB . $strPath;
		$AppUI->image_path					= $strPath;
		$_SESSION['Zend_Auth']['storage'] 	= $AppUI;
		$strMessage	= $arrMessage[4];
	}
	else {
		$intError = $arrImg['error'];
		$strMessage	= $arrMessage[7];
	}
} 
echo '{error:\'' . $intError . "',\n" . 'msg: \'' . $strMessage . "',\n" . 'path:\'' . $strLink . "'\n}";
exit();
?>